package com.napenalki.toto.converter;

import org.springframework.core.convert.converter.Converter;

import com.napenalki.toto.domain.Stages;

public class StagesConverter implements Converter<String, Stages> {

    @Override
    public Stages convert(String source) {
        if (source.toLowerCase().startsWith("group")) {
            return Stages.valueOf(source.toUpperCase().replace(' ', '_'));
        }
        
        if (source.equalsIgnoreCase("small final")) {
            return Stages.SMALL_FINAL;
        }
        
        return Stages.valueOf(source.toUpperCase());
    }

    
}
